package cn.wolfcode.p2p;

import cn.wolfcode.p2p.interceptor.CheckLoginInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SpringBootApplication
@EnableScheduling //开启定时器
public class MgrsiteConfig extends WebMvcConfigurerAdapter{

    /**
     * 配置拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/*")
                .excludePathPatterns("/mgrLogin");
    }

    @Bean
    public CheckLoginInterceptor loginInterceptor(){
        return new CheckLoginInterceptor();
    }

    public static void main(String[] args) {
        SpringApplication.run(MgrsiteConfig.class,args);
    }
}
